package 尚硅谷juc大厂.test11;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

public class Test11 {
    static AtomicBoolean atomic=new AtomicBoolean(false);
    public static void main(String[] args) throws InterruptedException {
        new Thread(()->{
            while (true){
                if (atomic.get()){
                    System.out.println("程序结束......");
                    break;
                }
                System.out.println("t1线程运行输出.......");
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"t1").start();

        TimeUnit.SECONDS.sleep(5);
        new Thread(()->{
            atomic.set(true);
        }).start();
    }
}
